package com.taotao.manage.controller.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.taotao.manage.pojo.ItemDesc;
import com.taotao.manage.service.ItemDescService;

@Controller
@RequestMapping("api/item/desc")
public class ApiItemDescController {
	
	@Autowired
	private ItemDescService itemDescService;
	
	@RequestMapping(value="{itemId}",method = RequestMethod.GET)
	public ResponseEntity<ItemDesc> showItemDesc(@PathVariable("itemId")Long id){
		try {
			if (id == null || id.longValue() <= 0) {
				return ResponseEntity.badRequest().build();
			}
			ItemDesc record = new ItemDesc();
			record.setItemId(id);
			ItemDesc itemDesc = itemDescService.queryOne(record);
			if (itemDesc == null) {
				return ResponseEntity.notFound().build();
			}
			return ResponseEntity.ok(itemDesc);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
	
	
}
